<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="./js/echarts.js"></script>
</head>
<body>

    <div id="mains" style="width: 600px; height: 300px;display: inline-block;"></div>
    <div id="main" style="width: 600px; height: 300px;display: inline-block;"></div>
    <script>
        var Myecharts = echarts.init(document.getElementById("main"));
        var Myechartss = echarts.init(document.getElementById("mains"));
        option = {
            legend:{
                type: 'scroll',
                // left:30,
                data:['直接访问',"邮件营销","联盟广告","视频广告","搜索引擎"],
           },
        //    显示数据
           tooltip: {
                // trigger: 'axis'
                trigger: 'item',
                formatter: '{a} <br/>{b} : {c} ({d}%)'
            },
            xAxis: {
                type: 'category',
                data:['直接访问',"邮件营销","联盟广告","视频广告","搜索引擎"],
            },
            yAxis: {
                type: 'value'
            },
            series: [{
                name:'姓名',
                radius: '55%',
                center: ['40%', '50%'],
                data: [
                    {name:'直接访问',value:1350}, 
                    {name:'邮件营销',value:1200},
                    {name:'联盟广告',value:800},
                    {name:"视频广告",value:280},
                    {name:'搜索引擎',value:200}],
                type: 'bar',
                areaStyle:{normal:{}},
                smooth:true,
                stack:"总量",
                emphasis: {
                    itemStyle: {
                        shadowBlur: 10,
                        shadowOffsetX: 0,
                        shadowColor: 'rgba(0, 0, 0, 0.5)'
                    }
                }
            }],
           
        };

        //    渲染图表
        Myecharts.setOption(option);
      
            
        delete option.xAxis;
        delete option.yAxis;
        for(let i=0;i<option.series.length;i++){
            option.series[i].type='pie';
            // alert(i);
        }
        
        Myechartss.setOption(option);


    </script>
</body>
</html>